<%@ tag pageEncoding="utf-8" trimDirectiveWhitespaces="true" body-content="empty" %>
<%@ attribute name="value" type="java.lang.String" required="true" %>
<%@ attribute name="length" type="java.lang.Integer" required="false" %>
<%@ attribute name="isShowOnEmpty" type="java.lang.Boolean" required="false" description="defualt to datetime" %>
<%@ attribute name="fuzzyStart" type="java.lang.Integer" required="false" %>
<%@ attribute name="fuzzyEnd" type="java.lang.Integer" required="false" %>

<%@ attribute name="replaceNewLineSlashN" type="java.lang.Integer" %>

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
    if(value==null || "".equals(value)) {
        if(new Boolean(true).equals(isShowOnEmpty)) {
            out.print("--");
        }
    }else {
        int valueLength = value.length();
        String outStr = value;

        if(fuzzyStart !=null && fuzzyStart >= 0) {
            //如果有模糊开始
            if(fuzzyEnd !=null && fuzzyEnd > fuzzyStart) {
                //如果有结束，从开始到结束 用“*”代替
            }else {
                //如果没有结束，从开始位置之后，都用“*”代替

                StringBuilder sb = new StringBuilder();
                for(int i=fuzzyStart; i<valueLength; i++) {

                }
            }
        }

        //替换 \n
        if(replaceNewLineSlashN == null) {
            outStr = outStr.replaceAll("\n", "");
        }else if(replaceNewLineSlashN == 1) {
            //替换 \n 为 \\n
            outStr = outStr.replaceAll("\n", "\\\\n");
        }else if(replaceNewLineSlashN == 2) {
            outStr = outStr.replaceAll("\n", "<br>");
        }else if(replaceNewLineSlashN == 3) {
            //不替换
        }

        if(length==null || length<=0) {
            out.print(outStr);
        }else {
            //有长度限制
            if(valueLength <= length) {
                out.print(outStr);
            }else {
                outStr = value.substring(0, length-1);
                outStr += "...";
                out.print(outStr);
            }
        }
    }
%>

